from rich.console import Console
from rich.theme import Theme

console = Console()

# 定义自定义主题
themes = {
    "dark": Theme({
        "info": "dim cyan",
        "warning": "magenta",
        "error": "bold red"
    }),
    "light": Theme({
        "info": "blue",
        "warning": "yellow",
        "error": "red"
    })
}

# 动态切换主题
current_theme = themes["dark"]
console.print(f"[bold {current_theme['info']}]已切换至暗黑主题[/bold {current_theme['info']}]")
console.print(f"[{current_theme['warning']}]这是一条警告信息[/]", end="")
console.print(f"[{current_theme['error']}]系统错误！[/]")